package com.dwxt.cdms.controller;

import com.dwxt.cdms.service.ManagerService;
import com.dwxt.common.annotation.ValidateFiled;
import com.dwxt.common.annotation.ValidateGroup;
import com.dwxt.common.base.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/cdms/manager")
@RestController
public class ManagerController {

    @Autowired
    private ManagerService managerService;
    /**
     * 判断我是否是管理员
     */
    @RequestMapping("/judge")
    @ValidateGroup(fileds = {
            @ValidateFiled(index = 0, regStr = "^1[3|4|5|6|7|8|9][0-9]\\d{4,8}$"),
    })
    public BaseResult judge(String phone){
        return managerService.judge(phone);
    }

    /**
     * 查找可以查看 我管理的老人 的关联人
     */
    @RequestMapping("/selectMyOldRelation")
    @ValidateGroup(fileds = {
            @ValidateFiled(index = 0, regStr = "^1[3|4|5|6|7|8|9][0-9]\\d{4,8}$"),
    })
    public BaseResult selectMyOldRelation(String phone) {
        return managerService.selectMyOldRelation(phone);
    }

    /**
     * 添加管理电话
     */
    @RequestMapping("/bindWithPhone")
    @ValidateGroup(fileds = {
            @ValidateFiled(index = 1, regStr = "^1[3|4|5|6|7|8|9][0-9]\\d{4,8}$"),
    })
    public BaseResult bindWithPhone(Integer relateId, String phone) {
        return managerService.bindWithPhone(relateId, phone);
    }
}
